package com.power.controller;

import com.alibaba.fastjson.JSONObject;
import com.power.ov.ResultData;
import com.power.service.UsersService;
import com.power.service.impl.UsersServiceImpl;
import com.power.utils.WriterUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2020/10/11 19:25
 * Description:
 * Version: V1.0
 */
@WebServlet("/updateAuthority.do")
public class UpdateAuthority extends HttpServlet {
    UsersService service=new UsersServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String roleId=req.getParameter("role_id");
        String data=req.getParameter("data");
        List<Map> list= JSONObject.parseArray(data,Map.class);
        ResultData resultData=new ResultData();
        try {
            resultData=service.updateAuthority(roleId,list);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        WriterUtil.getWriter(resp,resultData);
    }
}
